package com.yuhs.zixing.study.design.pattern.dp001.principle.p02.interface_segregation;

/**
 * @description 没有使用  接口隔离原则
 * @author: yuhs
 * @date 2022/3/24 上午9:29
 */
public class InterfaceSegregationDemo001 {


    public static void main(String[] args) {

    }


}

interface InterfaceDemo001 {
    void operationA();

    void operationB();

    void operationC();

    void operationD();

    void operationE();
}

class B implements InterfaceDemo001 {

    @Override
    public void operationA() {
        System.out.println("B 实现了 operationA");
    }

    @Override
    public void operationB() {
        System.out.println("B 实现了 operationB");
    }

    @Override
    public void operationC() {
        System.out.println("B 实现了 operationC");
    }

    @Override
    public void operationD() {
        System.out.println("B 实现了 operationD");
    }

    @Override
    public void operationE() {
        System.out.println("B 实现了 operationE");
    }
}

class D implements InterfaceDemo001 {

    @Override
    public void operationA() {
        System.out.println("D 实现了 operationA");
    }

    @Override
    public void operationB() {
        System.out.println("D 实现了 operationB");
    }

    @Override
    public void operationC() {
        System.out.println("D 实现了 operationC");
    }

    @Override
    public void operationD() {
        System.out.println("D 实现了 operationD");
    }

    @Override
    public void operationE() {
        System.out.println("D 实现了 operationE");
    }
}

/**
 * A类通过接口 InterfaceDemo001 依赖（使用）B,但是只会用到A、B、C方法
 */
class A {

    public void dependA(InterfaceDemo001 i) {
        i.operationA();
    }

    public void dependB(InterfaceDemo001 i) {
        i.operationB();
    }

    public void dependC(InterfaceDemo001 i) {
        i.operationC();
    }


}

/**
 * C类通过接口 InterfaceDemo001 依赖（使用）B,但是只会用到A、D、E方法
 */
class C {

    public void dependA(InterfaceDemo001 i) {
        i.operationA();
    }

    public void dependD(InterfaceDemo001 i) {
        i.operationD();
    }

    public void dependE(InterfaceDemo001 i) {
        i.operationE();
    }
}
